package org.scirp.ijmis.dao.personpaper.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import oracle.net.aso.h;

import org.scirp.ijmis.dao.base.impl.BaseDAOImpl;
import org.scirp.ijmis.dao.personpaper.ILoginDAO;
import org.scirp.ijmis.dao.personpaper.ILoginInformationDAO;
import org.scirp.ijmis.po.personpaper.Login;
import org.scirp.ijmis.po.personpaper.LoginInformation;

public class LoginInformationDAOImpl extends BaseDAOImpl<LoginInformation> implements ILoginInformationDAO {

	private static final String className = LoginInformationDAOImpl.class.toString();

	public Long saveLoginInformation(LoginInformation loginInformation) {
		return super.saveObject(loginInformation, className + "-->saveLoginInformation(LoginInformation loginInformation)");
	}

	public List<LoginInformation> selectAll() {
		return null;
	}
	public boolean deleteByPersonId(Long personId) {
		String hql="delete from LoginInformation where personId=:personId";
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("personId", personId);
		return super.ExecuteNonQuery(hql, map, className+"deleteByPersonId(Long personId)");
	}
	public List<LoginInformation> selectByPersonId(long personId, Long loginTimeNumbers) {
		String sql = "SELECT * FROM (SELECT * FROM t_logininformation WHERE personid = " + personId + " order by datetimein desc) where ROWNUM <= " + loginTimeNumbers;

		List<LoginInformation> selectLoginInformation = (List<LoginInformation>) getSession().createSQLQuery(sql).addEntity(LoginInformation.class).list();

		return selectLoginInformation;
	}
}
